package thread;
//让t线程等待main
public class Demo12 {
   
    
    public static void main(String[] args) throws InterruptedException {
         //获取到main的引用
        Thread mainThread =Thread.currentThread();
        
        Thread t = new Thread(() -> {
            //让t线程等待main线程
            System.out.println("t线程开始等待");
            try {
                mainThread.join();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println("t线程等待结束");
            
            
        });
        t.start();
        //让main执行一段逻辑
        for(int i=0;i<5;i++){
            System.out.println("hello main");
            Thread.sleep(1000);
        }
    }
}
